import { _decorator, Button, Label } from 'cc';
import { ccbutton, ccclass, cccomponent, ccmodifier, HintAlert } from '../../../extensions/cc-feather/assets/src';

/**
 * - 作者: DoooReyn
 * - 日期: 2023.11.02
 * - 名称: AlertCommon
 * - 描述: 通用警告提示
 */
@ccclass()
@ccmodifier('AlertCommon')
export class AlertCommon extends HintAlert {
    @cccomponent(Label, 'Background/LabTitle')
    private __labTitle: Label;

    @cccomponent(Label, 'Background/LabContent')
    private __labContent: Label;

    @cccomponent(Label, 'Background/BtnConfirm/Label')
    private __labConfirm: Label;

    @cccomponent(Label, 'Background/BtnReject/Label')
    private __labReject: Label;

    @ccbutton({ func: 'onConfirm' }, 'Background/BtnConfirm')
    private __btnConfirm: Button;

    @ccbutton({ func: 'onReject' }, 'Background/BtnReject')
    private __btnReject: Button;

    protected setContent(): void {
        if (!this._cfg || !this.__labContent) return;

        this.__labContent.string = this._cfg.tip;
        if ((this.__labTitle.node.active = !!this._cfg.title)) {
            this.__labTitle.string = this._cfg.title;
        }
        if (this._cfg.confirmText) {
            this.__labConfirm.string = this._cfg.confirmText;
        }
        if (this._cfg.rejectText) {
            this.__labReject.string = this._cfg.rejectText;
        }
    }
}
